<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var str = 'abcdefg'
        //  创建新的字符串接收结果
        var newStr = ''
        //  从字符串str最后一个值遍历数组，并依次输入到新的字符串
        for (var i = str.length - 1; i >= 0; i--) {
            newStr += str[i]
        }
        console.log(newStr)
    </script>
</body>

</html>